package com.cheng.util;

import java.io.File;

import com.sun.org.apache.xml.internal.security.utils.Base64;

public class CreateQRCode {
	private String m;
	private String p;
	private String s;
	
	public void createCode(String imgPath,String masterString,String privateString){
		p = Base64.encode(RSA.encrypt(privateString));
		m = masterString + "/" + SHA1.toSHA1(p);
		s = Base64.encode(RSA.encrypt(SHA1.toSHA1(m)));
		System.out.println("p:" + p.length());
		System.out.println("m:" + m.length());
		System.out.println("s:" + s.length());
		
		String path = imgPath + "test";
		File dir = new File(path);
		dir.mkdirs();
		TwoDimensionCode handler = new TwoDimensionCode();
		handler.encoderQRCode(p, path + "/数字私章.png");
		handler.encoderQRCode(m, path + "/数字母章.png");
		handler.encoderQRCode(s, path + "/数字子章.png");
		System.out.println("保存成功!");
		
		System.out.println("p:" + handler.decoderQRCode(path + "/数字私章.png"));
		System.out.println("m:" + handler.decoderQRCode(path + "/数字母章.png"));
		System.out.println("s:" + handler.decoderQRCode(path + "/数字子章.png"));
		
	}
	
	public static void main(String[] args) {
		String ms = "张三/电子科技大学/19920419/2906006017/成都/萍乡/2013/Swing显示图片可以有很多的种选择，例如：可以用JLabel和JTable等， ";
		String ps = "你的生日�?19920419";
		new CreateQRCode().createCode("d:/",ms,ps);
	}
}
